﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


public class TimeJob
{
    public DataSetHelper dataSetHelper = new DataSetHelper();
    public SyncDataList syncDataList = new SyncDataList();
    public   void ExecuteJob(int intHour, int intMinute, int intSecond, SysConfig config)
    {
        string url = config.WebService;

        bool xsDate1 = false;
        bool yyyDate1 = false;
        bool spDate1 = false;

        bool xsDate2 = false;
        bool yyyDate2 = false;
        bool spDate2 = false;

        bool xsDate3 = false;
        bool yyyDate3 = false;
        bool spDate3 = false;


        bool xsDate4 = false;
        bool yyyDate4 = false;
        bool spDate4 = false;



        int type_xs = config.SalesRate;//销售频率
        switch (type_xs)
        {
            case 1:
                xsDate1 = true;
                break;
            case 2:
                xsDate2 = true;
                break;
            case 3:
                xsDate3 = true;
                break;
            case 4:
                xsDate4 = true;
                break;
            default:
                break;

        }

        int type_yyy = config.EmployeeRate;//收银员频率
        switch (type_yyy)
        {
            case 1:
                yyyDate1 = true;
                break;
            case 2:
                yyyDate1 = true;
                break;
            case 3:
                yyyDate1 = true;
                break;
            case 4:
                yyyDate1 = true;
                break;
            default:
                break;
        }

        int type_spda = config.SpdaRate;//商品档案频率
        switch (type_spda)
        {
            case 1:
                spDate1 = true;
                break;
            case 2:
                spDate1 = true;
                break;
            case 3:
                spDate1 = true;
                break;
            case 4:
                spDate1 = true;
                break;
            default:
                break;

        }


        //每天
        #region  每天一次操作

        string time = DateTime.Now.ToString("yyyy-MM-dd");
        if (xsDate4 && intHour > 11)
        {
            syncDataList.UpLoadData(url);
            //  SetSystemInfo("XSSJ", time);
        }
        if (yyyDate4 && intHour > 11)
        {
            syncDataList.DownloadGetYyyH(url);
            //  SetSystemInfo("YYYDA", time);

        }
        if (spDate4 && intHour > 11)
        {
            syncDataList.DownloadGetCpdaH(url);
            //    SetSystemInfo("SPDA", time);
        }


        #endregion



        //每小时
        if (intMinute == 58 && intSecond == 58)
        {
            if (xsDate1)
            {
                syncDataList.UpLoadData(url);

            }
            if (yyyDate1)
            {
                syncDataList.DownloadGetYyyH(url);
            }
            if (spDate1)
            {
                syncDataList.DownloadGetCpdaH(url);

            }
        }


        //每分钟
        if (intSecond == 58)
        {
            if (xsDate2)
            {
                syncDataList.UpLoadData(url);
            }
            if (yyyDate2)
            {
                syncDataList.DownloadGetYyyH(url);
            }
            if (spDate2)
            {
                syncDataList.DownloadGetCpdaH(url);
            }
        }

        //每秒

        if (xsDate3)
        {
            syncDataList.UpLoadData(url);
        }
        if (yyyDate3)
        {
            syncDataList.DownloadGetYyyH(url);
        }
        if (spDate3)
        {
            syncDataList.DownloadGetCpdaH(url);
        }
    }


}

